<?php
require_once 'phpmoko/lib/common.php';

class Cookie
{
	private $name;
	private $expire;
	private $domain;
	private $path;
	private $secure;
	private $value = null;

	function Cookie($name, $expire = 0, $domain = null, $path = null, $secure = false)
	{
		$this->name = $name;
		$this->expire = $expire;
		$this->domain = $domain;
		$this->path = $path;
		$this->secure = $secure;

		if (isset($_COOKIE[$this->name]))
			$this->value = $_COOKIE[$this->name];
	}

	function setValue($value)
	{
		setcookie($this->name, $value, $this->expire, $this->path, $this->domain, $this->secure, TRUE);
		$this->value = $value;
	}

	function getValue()
	{
		return $this->value;
	}

	function delete()
	{
		$this->value = null;
		setcookie($this->name, "", time() - 3600, $this->path, $this->domain, $this->secure, TRUE);
	}
}
?>